package com.company.jrlz.web.screens.device;

import com.company.jrlz.entity.WorkStation;
import com.haulmont.cuba.gui.components.HasValue;
import com.haulmont.cuba.gui.model.InstanceContainer;
import com.haulmont.cuba.gui.screen.*;
import com.company.jrlz.entity.Device;

import javax.inject.Inject;

@UiController("jrlz_Device.edit")
@UiDescriptor("device-edit.xml")
@EditedEntityContainer("deviceDc")
@LoadDataBeforeShow
public class DeviceEdit extends StandardEditor<Device> {
    @Inject
    private InstanceContainer<Device> deviceDc;

    @Subscribe("workStationField")
    public void onWorkStationFieldValueChange(HasValue.ValueChangeEvent<WorkStation> event) {
        deviceDc.getItemOrNull().setLine(event.getValue().getLine().getLineName());
    }
}